{% extends "layout.html" %}

{% block title %}User Management{% endblock %}


{% block content %}
<ul class="nav nav-tabs custom-tab">
    <li class="active"><a href="#" data-toggle="tab"><i class="icon-list"></i><span>Users</span></a></li>
    <li><a href="{{ base_url }}admin/user.php?action=add" data-toggle="tab"><i class="icon-user"></i><span>Add User</span></a></li>
</ul>
<div class="user-list">
    <h2>User Management</h2>
    <table class="table table-striped table-bordered table-condensed">
        <thead>
            <tr>
                <th>Username</th>
                <th>Email</th>
                <th>Name</th>
                <th>Action</th>
            </tr>

        </thead>
        <tbody>
            {% for user in users %}
            <tr>
                <td>{{ user.username|e }}</td>
                <td>{{ user.email }}</td>
                <td>{{ user.first_name }} {{ user.last_name }}</td>
                <td>

                    <a href="{{base_url}}admin/user.php?action=edit&user_id={{ user.id }}" rel="tooltip" title="Edit" ><i class=" icon-pencil"></i></a>
                    <a href="{{base_url}}admin/user.php?action=view&user_id={{ user.id }}" rel="tooltip" title="View"><i class="icon-eye-open"></i></a>
                    <a href="{{base_url}}admin/user.php?action=delete&user_id={{ user.id }}" rel="tooltip" title="Delete" class="delete"><i class="icon-remove"></i></a>
                </td>
            </tr>  
            {% endfor %}
        </tbody>
    </table>
</div>
<div id="modalDelete" class="modal hide">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">x</button>
        <h3>Confirm delete user</h3>
    </div>
    <div class="modal-body">
        <p>Do you want to delete user?</p>
    </div>
    <div class="modal-footer">
        <a href="#" class="btn" data-dismiss="modal">No</a>
        <a href="#" id="deleteLink" class="btn btn-primary">Yes</a>
    </div>
</div>
<script src="{{base_url}}/admin/js/bootstrap-modal.js"></script>
<script>
    $(document).ready(function(){
        $('a[rel="tooltip"]').tooltip();
        
        //Delete user
        $('.delete').click(function(e){
            var deleteURL = $(this).attr('href');
            $('#deleteLink').attr('href', deleteURL);
            
            $('#modalDelete').modal({
                keyboard: false
                
            });
            e.preventDefault();
        })
        
    })
</script>
{% endblock %}